home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / personalpaint7.lha / PPaint / Rexx / BrushFormat.pprx < prev    next >
Encoding:
Text File  |  1997-04-19  |  3.8 KB  |  151 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1997 Cloanto Italia srl */
  2.  
  3. /* $VER: BrushFormat.pprx 1.1 */
  4.  
  5. /** ENG
  6.  This script makes it possible to exactly set a new brush
  7.  format (size and number of colors).
  8.  
  9.  The new brush size can be specified in pixels or in
  10.  percentage of the original size. A value of 0 in one of
  11.  the two fields indicates that the original aspect ratio
  12.  should be preserved.
  13.  
  14.  If the brush size is reduced and the number of colors
  15.  is increased, and the "Color Average Resize" setting
  16.  is enabled, then the brush palette is extended with new
  17.  colors. This results in better antialiasing.
  18. */
  19.  
  20.  
  21. IF ARG(1, EXISTS) THEN
  22.     PARSE ARG PPPORT
  23. ELSE
  24.     PPPORT = 'PPAINT'
  25.  
  26. IF ~SHOW('P', PPPORT) THEN DO
  27.     IF EXISTS('PPaint:PPaint') THEN DO
  28.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  29.         DO 30 WHILE ~SHOW('P',PPPORT)
  30.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  31.         END
  32.     END
  33.     ELSE DO
  34.         SAY "Personal Paint could not be loaded."
  35.         EXIT 10
  36.     END
  37. END
  38.  
  39. IF ~SHOW('P', PPPORT) THEN DO
  40.     SAY 'Personal Paint Rexx port could not be opened'
  41.     EXIT 10
  42. END
  43.  
  44. ADDRESS VALUE PPPORT
  45. OPTIONS RESULTS
  46. OPTIONS FAILAT 10000
  47.  
  48. Get 'LANG'
  49. IF RESULT = 1 THEN DO        /* Deutsch */
  50.     txt_title_format  = "Brush Format"        /* *** ENG */
  51.     txt_gad_width     = "_Width:"
  52.     txt_gad_height    = "_Height:"
  53.     txt_gad_unit      = "_Unit:"
  54.     txt_gad_unit0     = "Pixels"
  55.     txt_gad_unit1     = "Percentage"
  56.     txt_gad_colors    = "C_olors:"
  57.     txt_err_oldclient = "Für dieses Skript_ist eine neuere Version_von Personal Paint erforderlich"
  58. END
  59. ELSE IF RESULT = 2 THEN DO    /* Italiano */
  60.     txt_title_format  = "Formato pennello"
  61.     txt_gad_width     = "_Larghezza:"
  62.     txt_gad_height    = "Al_tezza:"
  63.     txt_gad_unit      = "_Unità:"
  64.     txt_gad_unit0     = "Pixel"
  65.     txt_gad_unit1     = "Percentuale"
  66.     txt_gad_colors    = "C_olori:"
  67.     txt_err_oldclient = "Questa procedura richiede_una versione più recente_di Personal Paint"
  68. END
  69. ELSE DO            /* English */
  70.     txt_title_format  = "Brush Format"
  71.     txt_gad_width     = "_Width:"
  72.     txt_gad_height    = "_Height:"
  73.     txt_gad_unit      = "_Unit:"
  74.     txt_gad_unit0     = "Pixels"
  75.     txt_gad_unit1     = "Percentage"
  76.     txt_gad_colors    = "C_olors:"
  77.     txt_err_oldclient = "This script requires a newer_version of Personal Paint"
  78. END
  79.  
  80. Version 'REXX'
  81. IF RESULT < 7 THEN DO
  82.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  83.     EXIT 10
  84. END
  85.  
  86. LockGUI
  87. GetCurrentBrush
  88. currbsh = RESULT
  89. custombsh = (WORD(currbsh, 1) = 'BRUSH')
  90.  
  91. GetBrushAttributes 'WIDTH'
  92. bwidth = RESULT
  93. GetBrushAttributes 'HEIGHT'
  94. bheight = RESULT
  95.  
  96. req = ,
  97.    'INTSTR = ""'txt_gad_width'"", 0, 32000, 'bwidth' ' ||,
  98.    'INTSTR = ""'txt_gad_height'"", 0, 32000, 'bheight' ' ||,
  99.    'CYCLE = ""'txt_gad_unit'"", 2, 0, ""'txt_gad_unit0'"", ""'txt_gad_unit1'""'
  100.  
  101. IF custombsh THEN DO
  102.     GetBrushAttributes 'COLORS'
  103.     bcolors = RESULT
  104.     DO bdepth = 1 TO 8
  105.         IF 2 ** bdepth = bcolors THEN
  106.             BREAK
  107.     END
  108.     req = req ||,
  109.         ' SEPARATOR ' ||,
  110.         ' COLSLIDE = ""'txt_gad_colors'"", 1, 8, 'bdepth
  111. END
  112.  
  113. Request '"'txt_title_format'" "'req'"'
  114. IF RC = 0 THEN DO
  115.     new_bwidth  = RESULT.1
  116.     new_bheight = RESULT.2
  117.     unit        = RESULT.3
  118.     IF custombsh THEN
  119.         new_bcolors = 2 ** RESULT.4
  120.  
  121.     IF unit = 1 THEN DO
  122.         new_bwidth  = TRUNC(bwidth * new_bwidth / 100 + 0.5)
  123.         new_bheight = TRUNC(bheight * new_bheight / 100 + 0.5)
  124.     END
  125.  
  126.     IF new_bwidth ~= 0 | new_bheight ~= 0 THEN DO
  127.         IF new_bwidth = 0 THEN
  128.             new_bwidth = TRUNC(new_bheight * (bwidth / bheight) + 0.5)
  129.  
  130.         IF new_bwidth < 1 THEN
  131.             new_bwidth = 1
  132.  
  133.         IF new_bheight = 0 THEN
  134.             new_bheight = TRUNC(new_bwidth / (bwidth / bheight) + 0.5)
  135.  
  136.         IF new_bheight < 1 THEN
  137.             new_bheight = 1
  138.  
  139.         IF custombsh THEN DO
  140.             IF new_bwidth ~= bwidth | new_bheight ~= bheight | new_bcolors ~= bcolors THEN
  141.                 SetBrushAttributes 'WIDTH' new_bwidth 'HEIGHT' new_bheight 'COLORS' new_bcolors 'EXTENDPALETTE'
  142.         END
  143.         ELSE DO
  144.             IF new_bwidth ~= bwidth | new_bheight ~= bheight THEN
  145.                 SetCurrentBrush WORD(currbsh,1) 'WIDTH' new_bwidth 'HEIGHT' new_bheight
  146.         END
  147.     END
  148. END
  149.  
  150. UnlockGUI
  151.